//
//  UserModel.m
//  FindJob
//
//  Created by 233 on 16/2/29.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "UserModel.h"

#define kAccountInfo @"accountInfo"
#define kAccountNumber @"accountNumber"
#define kAccountPassword @"password"
@implementation UserModel
+ (instancetype)shareUserModel{
    static UserModel *model = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
       model = [[UserModel alloc] init];
        model.isLogin = NO;
    });
    return model;
}
- (void)saveAccountAndPassword{
    NSDictionary *userDict = @{kAccountNumber:self.account,
                               kAccountPassword:self.password};
    [[NSUserDefaults standardUserDefaults] setObject:userDict forKey:kAccountInfo];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)readAccountAndPassword{
    NSDictionary *userDict = [[NSUserDefaults standardUserDefaults] objectForKey:kAccountInfo];
    if (!userDict) {
        self.account = @"";
        self.password = @"";
        return;
    }
    self.account = userDict[kAccountNumber];
    self.password = userDict[kAccountPassword];
    
}
@end
